package com.csii.modules.online.config.util;

import org.apache.commons.lang3.StringUtils;

public class MetaDataUtil {
	private String tableName;
	private String columnId;
	private String columnName;
	private int columnSize;
	private String colunmType;
	private String comment;
	private String fieldDefault;
	private int decimalDigits;
	private String isNullable;
	private String pkType;
	private String oldColumnName;

	@Override
	public boolean equals(Object obj) {
		if (obj == this) {
			return true;
		} else if (!(obj instanceof MetaDataUtil)) {
			return false;
		} else {
			MetaDataUtil var2 = (MetaDataUtil) obj;
			if (!this.colunmType.contains("date") && !this.colunmType.contains("blob") && !this.colunmType.contains("text")) {
				return this.colunmType.equals(var2.getColunmType()) && this.isNullable.equals(var2.isNullable) && this.columnSize == var2.getColumnSize() && this.compareStr(this.comment, var2.getComment()) && this.compareStr(this.fieldDefault, var2.getFieldDefault());
			} else {
				return this.columnName.equals(var2.getColumnName()) && this.isNullable.equals(var2.isNullable) && this.compareStr(this.comment, var2.getComment()) && this.compareStr(this.fieldDefault, var2.getFieldDefault());
			}
		}
	}

	public boolean compare(Object metaDataUtil, String dbType) {
		if (metaDataUtil == this) {
			return true;
		} else if (!(metaDataUtil instanceof MetaDataUtil)) {
			return false;
		} else {
			MetaDataUtil dataUtil = (MetaDataUtil) metaDataUtil;
			if ("SQLSERVER".equals(dbType)) {
				if (!this.colunmType.contains("date") && !this.colunmType.contains("blob") && !this.colunmType.contains("text")) {
					return this.colunmType.equals(dataUtil.getColunmType()) && this.isNullable.equals(dataUtil.isNullable) && this.columnSize == dataUtil.getColumnSize() && this.compareStr(this.fieldDefault, dataUtil.getFieldDefault());
				} else {
					return this.columnName.equals(dataUtil.getColumnName()) && this.isNullable.equals(dataUtil.isNullable);
				}
			} else if ("POSTGRESQL".equals(dbType)) {
				if (!this.colunmType.contains("date") && !this.colunmType.contains("blob") && !this.colunmType.contains("text")) {
					return this.colunmType.equals(dataUtil.getColunmType()) && this.isNullable.equals(dataUtil.isNullable) && this.columnSize == dataUtil.getColumnSize() && this.compareStr(this.fieldDefault, dataUtil.getFieldDefault());
				} else {
					return this.columnName.equals(dataUtil.getColumnName()) && this.isNullable.equals(dataUtil.isNullable);
				}
			} else if ("ORACLE".equals(dbType)) {
				if (!this.colunmType.contains("date") && !this.colunmType.contains("blob") && !this.colunmType.contains("text")) {
					return this.colunmType.equals(dataUtil.getColunmType()) && this.isNullable.equals(dataUtil.isNullable) && this.columnSize == dataUtil.getColumnSize() && this.compareStr(this.fieldDefault, dataUtil.getFieldDefault());
				} else {
					return this.columnName.equals(dataUtil.getColumnName()) && this.isNullable.equals(dataUtil.isNullable);
				}
			} else if (!this.colunmType.contains("date") && !this.colunmType.contains("blob") && !this.colunmType.contains("text")) {
				return this.colunmType.equals(dataUtil.getColunmType()) && this.isNullable.equals(dataUtil.isNullable) && this.columnSize == dataUtil.getColumnSize() && this.compareStr(this.comment, dataUtil.getComment()) && this.compareStr(this.fieldDefault, dataUtil.getFieldDefault());
			} else {
				return this.colunmType.equals(dataUtil.getColunmType()) && this.columnName.equals(dataUtil.getColumnName()) && this.isNullable.equals(dataUtil.isNullable) && this.compareStr(this.comment, dataUtil.getComment()) && this.compareStr(this.fieldDefault, dataUtil.getFieldDefault());
			}
		}
	}

	public boolean compareComment(MetaDataUtil var1) {
		return var1 == this ? true : this.compareStr(this.comment, var1.getComment());
	}

	public boolean compareCommentEq(MetaDataUtil var1) {
		return var1 == this || this.compareStr(this.comment, var1.getComment());
	}

	private boolean compareStr(String var1, String var2) {
		boolean var3 = StringUtils.isNotEmpty(var1);
		boolean var4 = StringUtils.isNotEmpty(var2);
		if (var3 != var4) {
			return false;
		} else {
			return !var3 || var1.equals(var2);
		}
	}

	public String getColumnName() {
		return this.columnName;
	}

	public int getColumnSize() {
		return this.columnSize;
	}

	public String getColunmType() {
		return this.colunmType;
	}

	public String getComment() {
		return this.comment;
	}

	public int getDecimalDigits() {
		return this.decimalDigits;
	}

	public String getIsNullable() {
		return this.isNullable;
	}

	public String getOldColumnName() {
		return this.oldColumnName;
	}

	@Override
	public int hashCode() {
		return this.columnSize + this.colunmType.hashCode() * this.columnName.hashCode();
	}

	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}

	public void setColumnSize(int columnSize) {
		this.columnSize = columnSize;
	}

	public void setColunmType(String colunmType) {
		this.colunmType = colunmType;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public void setDecimalDigits(int decimalDigits) {
		this.decimalDigits = decimalDigits;
	}

	public void setIsNullable(String isNullable) {
		this.isNullable = isNullable;
	}

	public void setOldColumnName(String oldColumnName) {
		this.oldColumnName = oldColumnName;
	}

	@Override
	public String toString() {
		return this.columnName + "," + this.colunmType + "," + this.isNullable + "," + this.columnSize;
	}

	public String getColumnId() {
		return this.columnId;
	}

	public void setColumnId(String columnId) {
		this.columnId = columnId;
	}

	public String getTableName() {
		return this.tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public String getFieldDefault() {
		return this.fieldDefault;
	}

	public void setFieldDefault(String fieldDefault) {
		this.fieldDefault = fieldDefault;
	}

	public String getPkType() {
		return this.pkType;
	}

	public void setPkType(String pkType) {
		this.pkType = pkType;
	}
}
